<template>
	<page-meta>
	    <navigation-bar
			title="设备录入--编辑"
			background-color="#EEEEEE"
			front-color="#ffffff "
	    />
	</page-meta>
    <view class="uni-padding-wrap">
		<view class="headerTitle">设备录入</view>
		<view class = "moudlBox">基本信息</view>
		<view class="uni-inline-item">
			<view class="uni-title">专业：</view>
			<text class="uni-text">{{domain}}</text>
			<view style = "width: 10%;"></view>
			<view class="uni-title">站台名称：</view>
			<text class="uni-text">{{stationName}}</text>
		</view>
		<view class="uni-inline-item">
			<view class="uni-title">系统名称：</view>
			<text class="uni-text">{{systemName}}</text>
			<view style = "width: 10%;"></view>
			<view class="uni-title">类型：</view>
			<text class="uni-text">{{etType}}</text>
		</view>
		<view class="uni-inline-item">
			<view class="uni-title">设备名称：</view>
			<text class="uni-text">{{etName}}</text>
			<view style = "width: 10%;"></view>
			<view class="uni-title">维修方式：</view>
			<text class="uni-text">计划维修</text>
		</view>
		<view class="uni-inline-item">
			<view class="uni-title">创建日期：</view>
			<text class="uni-text">{{createdTime}}</text>
			<view style = "width: 10%;"></view>
			<view class="uni-title">创建人：</view>
			<text class="uni-text">{{createdName}}</text>
		</view>
		<view class="uni-inline-item">
			<view class="uni-title">安装位置：</view>
			<text class="uni-text">{{installLocation}}</text>
			<view style = "width: 10%;"></view>
			<view class="uni-title">生命周期状态：</view>
			<text class="uni-text">{{life}}</text>
		</view>
		<view class="moudlBox">维修记录：</view>
		<view class="table">
			<z-table :tableData="nowData" singleSelect = "true" :columns="nowColumn" @onSort="doSort" :showLoading="false" :stickSide = "true"
			 @onClick="rowClick" :singleSelect="false"  @onSelect="tableSelect"></z-table>
		</view>
		<view class="pagesComBox">
			<uni-pagination :show-icon="true" :total="total" @change="change" pageSize="5"/>
		</view>
	</view>
</template>

<style>
	page{
		background-color: #F7F7F7;
	}
	.headerTitle{
		font-size: 18px;
		text-align: center;
	}
	.moudlBox{
		font-size: 20px;
		padding-top: 10px;
		color: #0A98D5;
	}
	.table{
		margin-top: 15px;
	}
</style>
<script>
	import tableTitleConst from '../../../common/tableTitleConst.js'
	import zTable from "@/components/z-table/z-table.vue";
	import uniPagination from '@/components/uni-pagination/uni-pagination.vue'
	import userInfoConst from '../../../common/userInfoConst.js'
	export default {
		components: {
			zTable,
			uniPagination
		},
		data() {
			return {
				total:0,//数据总数
				title: "设备台账数据表格",
				nowType: 0,
				nowData: false,
				nowColumn: false,
				nowHtml: '',
				emptyText:'暂无数据...',//数据为空时显示的wen
				myDebounce: this.debounce(this.setTable),
				selectContent: [
						{
							name: '左侧固定', // 功能名
							tableData: 'stickSideTableData', // 表格数据
							columns: 'stickSideColumns', // 表格列内容
							stickSide: true, // 左侧固定
							html: 'stickSideHtml'
						}
					],
					// 固定左侧
				stickSideTableData: [],
				stickSideColumns: ETMaintainTableColumns,
				stickSideHtml: '<z-table :stickSide = "true" :tableData="nowData" singleSelect = "true" :columns="nowColumn" :showLoading="false" @onClick="rowClick" @onSelect="tableSelect"></z-table>',
				pageNo:1,
				pageSize:5,
				lifeStatus:"",
				taskNum:"",
				maintainDate:"",
				maintainPerson:"",
				maintainContent:"",
				describe:"",
				taskStatus:"",
				createTime:"",
				createUserName:"",
				domain:"",
				systemName:"",
				createdId:userInfoConst.uid,
				createdName:userInfoConst.createUserName,
				createdTime:"",
				dateOfProduction:"",
				etName:"",
				etCode:"",
				lineId:"12",
				stationName:"",
				etModel:"",
				etType:"",
				etComment:"",
				maintain_way:"",
				etSupplier:"",
				etProducer:"",
				guaranteePeriod:"",
				serialNum:"",
				installLocation:"",
				installDate:"",
				professionalId:"",
				owner:"",
				voltage:"",
				power:"",
				life:"",
				isPlan:"",
				planBlea:false,
				maintainFristTime:"",
				maintain_this_time:"",
				maintainNextTime:"",
				intervalDay:"",
				maintainNextDay:"",
				eid:"",
			}
		},
		watch: {
			nowType: {
				handler() {
					this.nowData = false
					this.nowColumn = false
					this.myDebounce()
				},
				immediate: true
			}
		},
		onLoad: async function(option) {
			var eid = option.eid;
			
			await this.$myRequest({
				url:"/equipmentLAIM/getTableCodeAndValue/"+eid,
				method:"GET",
			}).then((res) => {
				if(res.code == "success"){
					var lineInfoList = res.mcAttrList[0].pzLine;
					var etMaintainPlanList = res.mcAttrList[0].etMaintainPlan;
					if(lineInfoList!=null){this.lineId = lineInfoList.lineId;}
					if(etMaintainPlanList!=null){
						this.intervalDay = etMaintainPlanList.intervalDay;
						this.isPlan = etMaintainPlanList.isPlan;
						this.maintain_way = etMaintainPlanList.maintainWay;
						this.maintainFristTime = etMaintainPlanList.maintainfirstTime;
						this.maintain_this_time = etMaintainPlanList.maintainthisTime;
						this.maintainNextTime = etMaintainPlanList.maintainnextTime;
						this.maintainNextDay = etMaintainPlanList.maintainnextDay;
					}
					if(this.isPlan == 1){
						this.planBlea = true;
						this.flag = true;
					}else{
						this.planBlea = false;
						this.flag = false;
					}
					// isPlanChange();
					var mcAttrInfoList = res.mcAttrList[0];
					this.eid = mcAttrInfoList.eid;
					this.createdId = userInfoConst.uid;
					this.createdName = userInfoConst.createUserName;
					this.createdTime = mcAttrInfoList.createdTime;
					this.dateOfProduction = mcAttrInfoList.dateOfProduction;
					this.domain = mcAttrInfoList.domain;
					this.etCode = mcAttrInfoList.etCode;
					this.etComment = mcAttrInfoList.etComment;
					this.etModel = mcAttrInfoList.etModel;
					this.etName = mcAttrInfoList.etName;
					this.etProducer = mcAttrInfoList.etProducer;
					this.etSupplier = mcAttrInfoList.etSupplier;
					this.etType = mcAttrInfoList.etType;
					this.guaranteePeriod = mcAttrInfoList.guaranteePeriod;
					this.installDate = mcAttrInfoList.installDate
					this.installLocation = mcAttrInfoList.installLocation;
					this.life = mcAttrInfoList.life;
					this.owner = mcAttrInfoList.owner;
					this.power = mcAttrInfoList.power;
					this.professionalId = mcAttrInfoList.professionalId;
					this.serialNum = mcAttrInfoList.serialNum;
					this.stationName = mcAttrInfoList.stationName;
					this.systemName = mcAttrInfoList.systemName;
					this.voltage = mcAttrInfoList.voltage;
					
					this.$myRequest({
						url:'/alertManager/queryMtRecord',
						method:"POST",
						data:{
								
								eventType:this.etType,
								systemName:this.systemName,
								stations:this.stationName,
								pageNo:this.pageNo,
								pageSize:this.pageSize,
								doMain:this.domain
							}
					}).then((res) => {
						if(res.code == 0){
							this.total = res.total;
							this.stickSideTableData = res.rows;
							this.nowData = this.$data[this.selectContent[this.nowType].tableData]
							this.nowColumn = this.$data[this.selectContent[this.nowType].columns]
							this.nowHtml = this.$data[this.selectContent[this.nowType].html]
						}else{
							uni.showToast({
								title:"queryMtRecord失败...",
								icon:"none"
							})
						}
					});
				}else{
					uni.showToast({
						title:"数据列表请求失败...",
						icon:"none"
					});
				}
			});
			
			// await uni.request({
			// 	url: "http://127.0.0.1:10100/equipmentLAIM/getTableCodeAndValue/"+eid,
			// 	success: (res) => {
			// 		if(res.data.code == "success"){
			// 			var lineInfoList = res.data.mcAttrList[0].pzLine;
			// 			var etMaintainPlanList = res.data.mcAttrList[0].etMaintainPlan;
			// 			if(lineInfoList!=null){this.lineId = lineInfoList.lineId;}
			// 			if(etMaintainPlanList!=null){
			// 				this.intervalDay = etMaintainPlanList.intervalDay;
			// 				this.isPlan = etMaintainPlanList.isPlan;
			// 				this.maintain_way = etMaintainPlanList.maintainWay;
			// 				this.maintainFristTime = etMaintainPlanList.maintainfirstTime;
			// 				this.maintain_this_time = etMaintainPlanList.maintainthisTime;
			// 				this.maintainNextTime = etMaintainPlanList.maintainnextTime;
			// 				this.maintainNextDay = etMaintainPlanList.maintainnextDay;
			// 			}
			// 			if(this.isPlan == 1){
			// 				this.planBlea = true;
			// 				this.flag = true;
			// 			}else{
			// 				this.planBlea = false;
			// 				this.flag = false;
			// 			}
			// 			// isPlanChange();
			// 			var mcAttrInfoList = res.data.mcAttrList[0];
			// 			this.eid = mcAttrInfoList.eid;
			// 			this.createdId = mcAttrInfoList.createdId;
			// 			this.createdName = mcAttrInfoList.createdName;
			// 			this.createdTime = mcAttrInfoList.createdTime;
			// 			this.dateOfProduction = mcAttrInfoList.dateOfProduction;
			// 			this.domain = mcAttrInfoList.domain;
			// 			this.etCode = mcAttrInfoList.etCode;
			// 			this.etComment = mcAttrInfoList.etComment;
			// 			this.etModel = mcAttrInfoList.etModel;
			// 			this.etName = mcAttrInfoList.etName;
			// 			this.etProducer = mcAttrInfoList.etProducer;
			// 			this.etSupplier = mcAttrInfoList.etSupplier;
			// 			this.etType = mcAttrInfoList.etType;
			// 			this.guaranteePeriod = mcAttrInfoList.guaranteePeriod;
			// 			this.installDate = mcAttrInfoList.installDate
			// 			this.installLocation = mcAttrInfoList.installLocation;
			// 			this.life = mcAttrInfoList.life;
			// 			this.owner = mcAttrInfoList.owner;
			// 			this.power = mcAttrInfoList.power;
			// 			this.professionalId = mcAttrInfoList.professionalId;
			// 			this.serialNum = mcAttrInfoList.serialNum;
			// 			this.stationName = mcAttrInfoList.stationName;
			// 			this.systemName = mcAttrInfoList.systemName;
			// 			this.voltage = mcAttrInfoList.voltage;
			// 			uni.request({
			// 				url:"http://127.0.0.1:10100/alertManager/queryMtRecord",
			// 				data:{
									
			// 						eventType:this.etType,
			// 						systemName:this.systemName,
			// 						stations:this.stationName,
			// 						pageNo:this.pageNo,
			// 						pageSize:this.pageSize,
			// 						doMain:this.domain
			// 					},
			// 				method:"POST",
			// 				success: (res) => {
			// 					if(res.data.code == 0){
			// 						this.total = res.data.total;
			// 						this.stickSideTableData = res.data.rows;
			// 						this.nowData = this.$data[this.selectContent[this.nowType].tableData]
			// 						this.nowColumn = this.$data[this.selectContent[this.nowType].columns]
			// 						this.nowHtml = this.$data[this.selectContent[this.nowType].html]
			// 					}else{
			// 						uni.showToast({
			// 							title:"queryMtRecord失败...",
			// 							icon:"none"
			// 						})
			// 					}
			// 				}
			// 			});
			// 		}else{
			// 			uni.showToast({
			// 				title:"数据列表请求失败...",
			// 				icon:"none"
			// 			});
			// 		}
			// 	}
			// });
		},
		methods: {
			//table表格
			setTable() {
				this.nowData = this.$data[this.selectContent[this.nowType].tableData]
				this.nowColumn = this.$data[this.selectContent[this.nowType].columns]
				this.nowHtml = this.$data[this.selectContent[this.nowType].html]
			},
			debounce(fn, time = 1000) {
				let timer = null 
				return function() {
					if (timer) clearTimeout(timer);
					timer = setTimeout(fn, time);
				}
			},
			change(e) {
				this.page = e.current;
				this.$myRequest({
					url:'/alertManager/queryMtRecord',
					method:"POST",
					data:{
							
							eventType:this.etType,
							systemName:this.systemName,
							stations:this.stationName,
							pageNo:this.pageNo,
							pageSize:this.pageSize,
							doMain:this.domain
						}
				}).then((res) => {
					if(res.code == 0){
						this.total = res.total;
						this.stickSideTableData = res.rows;
						this.nowData = this.$data[this.selectContent[this.nowType].tableData]
						this.nowColumn = this.$data[this.selectContent[this.nowType].columns]
						this.nowHtml = this.$data[this.selectContent[this.nowType].html]
					}else{
						uni.showToast({
							title:"queryMtRecord失败...",
							icon:"none"
						})
					}
				});
				// uni.request({
				// 	url:"http://127.0.0.1:10100/alertManager/queryMtRecord",
				// 	data:{
							
				// 			eventType:this.etType,
				// 			systemName:this.systemName,
				// 			stations:this.stationName,
				// 			pageNo:this.pageNo,
				// 			pageSize:this.pageSize,
				// 			doMain:this.domain
				// 		},
				// 	method:"POST",
				// 	success: (res) => {
				// 		if(res.data.code == 0){
				// 			this.total = res.data.total;
				// 			this.stickSideTableData = res.data.rows;
				// 			this.nowData = this.$data[this.selectContent[this.nowType].tableData]
				// 			this.nowColumn = this.$data[this.selectContent[this.nowType].columns]
				// 			this.nowHtml = this.$data[this.selectContent[this.nowType].html]
				// 		}else{
				// 			uni.showToast({
				// 				title:"queryMtRecord失败...",
				// 				icon:"none"
				// 			})
				// 		}
				// 	}
				// });
			}
		}
	}
</script>